package pers.ree.demo.concurrent.pool;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;

public class ThreadPoolExecutorDemo {

    public static void main(String[] args) {
        ExecutorService executorService = new ThreadPoolExecutor(2, 4,
                0L, TimeUnit.MILLISECONDS,
                new LinkedBlockingQueue<Runnable>(3));


        Runnable r = new Runnable() {
            @Override
            public void run() {
                while (true) {
//                    System.out.println(Thread.currentThread().getName());
                }
            }
        };

        for (int i=0; i<10; i++) {
            executorService.execute(r);
            System.out.println(i);
        }
    }
}
